/**
 * Copyright 20124-现在 weavecode
 */
package com.wcs.exam.common.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author wcs
 */
@Getter
@AllArgsConstructor
public enum UserSexEnum {

    MALE(1, "男", "green"), FEMALE(2, "女", "red"), SECRET(3, "保密", "orange");

    private final Integer code;

    private final String desc;

    private final String color;

    /**
     * 根据描述获取枚举
     *
     * @param desc 描述
     * @return 枚举
     */
    public static UserSexEnum byDesc(String desc) {
        if (StrUtil.isBlank(desc)) {
            return null;
        }
        for (UserSexEnum value : UserSexEnum.values()) {
            if (desc.equals(value.getDesc())) {
                return value;
            }
        }
        return null;
    }
}
